
function onLoadSection()
{
	setTitle( 'Параметры анкет' );
	
	$.fancybox.hideLoading();
	
	$( '#region_city > div ' ).click( function() { chooseClick( this ); }  )
	$( '#sex > div ' ).click( function() { chooseClick( this ); }  )
}

function chooseClick( this_ )
{	
	var thisEl = $( this_ );
	var sibling = $( thisEl.siblings()[ 0 ] );
	
	sibling.removeClass( "choose-item-selected" );
	sibling.addClass(  "choose-item-deselected" );
	thisEl.removeClass( "choose-item-deselected" );
	thisEl.addClass( "choose-item-selected" );

	$( thisEl.siblings()[ 1 ] ).val( thisEl.attr( 'name' ) );
}

function onContinue( nextSection_ )
{
	var keys = [ 'min_age', 'max_age', 'live_in', 'sex' ];
	var data = {};

	for( var i in keys )
	{
		var key = keys[ i ];
		data[ key ] = $( format( '[name={0}]', key ) ).val();
	}

	$.fancybox.showLoading();

	ajax(
		{
			url: "/save-search/",
			data: data,
			dataType: "json",
			success:
				function()
				{
					var nextSection = nextSection_ == null ? 4: nextSection_;
					loader.load( nextSection );
				},
			error:
				function()
				{
					alert( "error" );
				}
		}
	);
}